define([ 'util/JQuery', 'util/Knockout', 'domain/Achievement', 'util/ArrayUtil', 'util/Timer'], function($, ko, Achievement, arrayUtil, Timer) {
	'use strict';
	
	var model = function(achievementUrl) {
		var self = this;
		
		self.achievementUrl = achievementUrl;
		
		self.achievements = ko.observableArray([]);
						
		// attributes
		self.achievementLoad = function() {
			$.get("{0}".format(self.achievementUrl)).success(initAchievement);
		};

		var initAchievement = function(achievementJSON) {
			setAchievements(achievementJSON);
		};

		var setAchievements = function(achievementJSON) {
			arrayUtil.arrayExecuteChanges(self.achievements, convertToAchievement(achievementJSON));
		};
		
		// Converter methods
		var convertToAchievement = function(achievementJSON) {
			return $.map(achievementJSON, function(achievement) {
				return new Achievement(achievement.achievementId, achievement.achieved);
			});
		};
	
		self.achievementLoad();
		
	};

	return model;

});
